function reallocSinkReactType(p,n)
  use derived,only:SinkReactType
  implicit none

  type(SinkReactType),pointer,dimension(:) :: &
       reallocSinkReactType,p
  integer,intent(in) :: n

  integer :: i,j,k
  integer :: ierr,nd,nn

  allocate(reallocSinkReactType(1:n),stat=ierr)
  if (ierr.ne.0) call abnormal_stop("reallocSinkReactType",&
       "Memory allocation causes an error.")

  do i=1,n
     reallocSinkReactType(i)%gid=0
     reallocSinkReactType(i)%lid=0
     reallocSinkReactType(i)%n_data=0
     nullify(reallocSinkReactType(i)%react_eb)
     nullify(reallocSinkReactType(i)%react_nu)
     nullify(reallocSinkReactType(i)%react_rd)
     nullify(reallocSinkReactType(i)%react_rd2)
     nullify(reallocSinkReactType(i)%react_const_rate)
     nullify(reallocSinkReactType(i)%n_new)
     nullify(reallocSinkReactType(i)%new)
     reallocSinkReactType(i)%n_react_group=0
     nullify(reallocSinkReactType(i)%react_group)
  end do
  
  if (.not.associated(p)) return

  do i=1,n-1
     reallocSinkReactType(i)%gid=p(i)%gid
     reallocSinkReactType(i)%lid=p(i)%lid
     reallocSinkReactType(i)%n_data=p(i)%n_data
     nd=p(i)%n_data
     allocate(reallocSinkReactType(i)%react_eb(nd))
     allocate(reallocSinkReactType(i)%react_nu(nd))
     allocate(reallocSinkReactType(i)%react_rd(nd))
     allocate(reallocSinkReactType(i)%react_rd2(nd))
     allocate(reallocSinkReactType(i)%react_const_rate(nd))
     allocate(reallocSinkReactType(i)%n_new(nd))
     allocate(reallocSinkReactType(i)%new(nd))
     do j=1,nd
        reallocSinkReactType(i)%react_eb(j)=p(i)%react_eb(j)
        reallocSinkReactType(i)%react_nu(j)=p(i)%react_nu(j)
        reallocSinkReactType(i)%react_rd(j)=p(i)%react_rd(j)
        reallocSinkReactType(i)%react_rd2(j)=p(i)%react_rd2(j)
        reallocSinkReactType(i)%react_const_rate(j)=&
             p(i)%react_const_rate(j)
        reallocSinkReactType(i)%n_new(j)=p(i)%n_new(j)
        nn=p(i)%n_new(j)
        if (nn.gt.0) then
           allocate(reallocSinkReactType(i)%new(j)%prod_type(nn))
           do k=1,nn
              reallocSinkReactType(i)%new(j)%prod_type(k)=&
                   p(i)%new(j)%prod_type(k)
           end do
           deallocate(p(i)%new(j)%prod_type)
        end if
     end do
     deallocate(p(i)%react_eb)
     deallocate(p(i)%react_nu)
     deallocate(p(i)%react_rd)
     deallocate(p(i)%react_rd2)
     deallocate(p(i)%react_const_rate)
     deallocate(p(i)%n_new)
     deallocate(p(i)%new)
  end do

  deallocate(p)

  return

end function reallocSinkReactType
